<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 14:05:02
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:07:59
-->
<template>
  <div class="container">
    <div class="wrapper">
      <h3>{{ articleFor.title}}</h3>
      <div class="publishTime">{{ articleFor.publishTime | fmtDate }}</div>
      <div class="content" v-html="articleFor.content"></div>
      <!-- 报名 -->
      <div class="thumpUp">
        <el-button type="primary" @click="clickThumpUp()">点赞</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { get } from "@/utils/request";
export default {
  data() {
    return {
      id: "",
      articleFor: "",
    };
  },
  methods: {
    findArticleById() {
      get("/index/article/findById?id=" + this.id).then((res) => {
        if (res.status == 200) {
          this.articleFor = res.data;
        } else {
          this.$message({
            type: "error",
            message: this.message,
          });
        }
      });
    },
    // 点赞
    clickThumpUp() {
      get("/index/article/thumbUp?id=" + this.id).then((res) => {
        if (res.status == 200) {
          // console.log(res.message);
          this.$message({
            type: "success",
            message: res.message
            
          });
        } else {
          this.$message({
            type: "error",
            message: res.message,
            
          });
        }
      });
    },
  },
  created() {
    // 接受点击学生风采传递过来的参数
    this.id = this.$route.query.id;
    this.findArticleById();
  },
};
</script>

<style scoped lang='scss'>
.container {
  .wrapper {
    h3 {
      text-align: center;
    }
    .publishTime {
      text-align: center;
    }
    .thumpUp {
      text-align: center;
    }
  }
}
</style>